package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.*;
import com.sky.entity.User;

import java.util.List;
import java.util.Map;

@Mapper
public interface UserMapper{

    /**
    * 根据openid查询用户
    * @param openid
    * @return User
    */
    @Select("select * from user where openid = #{openid}")
    User getByOpenid(String openid);

    /**
    * 插入数据
    * @param user
    * @return void
    */
    void insert(User user);

    @Select("select * from user where id = #{id}")
    User getById(Long userId);

    //查询用户数量
    Integer countByMapTime(Map map);


    //用户管理

    @Delete("DELETE FROM user WHERE id = #{id}")
    void deleteById(Long id);

    @Update("UPDATE user SET name=#{name}, phone=#{phone}, sex=#{sex}, " +
            "id_number=#{idNumber}, avatar=#{avatar} WHERE id=#{id}")
    void update(User user);


    @Select("SELECT * FROM user")
    List<User> listAll();
}

